package game.breeze.socket.util;

public class ByteBufferWrapper implements BufferWrapper {
	private ByteBuffer buffer;

	public ByteBufferWrapper() {
		buffer = new ByteBuffer(512);
	}

	@Override
	public void writeInt(int value) {
		buffer.writeInt(value);
	}

	@Override
	public void put(byte[] data, int offset, int count) {
		buffer.writeBytes(data, offset, count);
	}

	@Override
	public void compact() {
		buffer.pack();
	}

	@Override
	public int remaining() {
		return buffer.available();
	}

	@Override
	public void clear() {
		buffer.clear();
	}

	public byte[] get(int length) {
		return buffer.readBytes(length);
	}

	@Override
	public int position() {
		// TODO Auto-generated method stub
		return buffer.position();
	}

	@Override
	public Object getBuffer() {
		return buffer;
	}

	@Override
	public void position(int newP) {
		buffer.position(newP);
	}
	
	@Override
	public int readInt() {
		// TODO Auto-generated method stub
		return buffer.readInt();
	}
	
	@Override
	public void reset() {
		
	}
}
